<?php
/**
 * Created by PhpStorm.
 * User: zd
 * Date: 2018/10/19
 * Time: 10:26
 */

namespace app\api\model;


class CardBase extends BaseModel
{
        protected $hidden=['id','w_id','sort','delete_time','create_time','update_time'];

    /**
     * 名片浏览量
     * @param $id
     * @return int|true
     */
    public static function browsing($w_id){
        $user = self::get(function($query) use($w_id){
            $query->where('w_id', $w_id);
        });
        $user->setInc('browsing_num');
        return $user->browsing_num;
    }
    /**
     * 名片点赞量
     * @param $uid
     * @param $w_id
     * @return mixed
     */
    public function thumgbsUp($w_id){
        $user = self::get(function($query) use($w_id){
            $query->where('w_id', $w_id);
        });
        $user->setInc('thumbsup_num');
        return $user->thumbsup_num;
    }
    /**
     * 获取名片基本信息表
     * @param $w_id
     * @return null|static
     */
    public function getCardBase($w_id){
        return self::get(function($query) use($w_id){
            $query->where('w_id', $w_id);
        });
    }
    /**
     * 更新名片信息
     * @param $info
     * @return false|int
     */
    public function updateCard($info,$wu_id){
        $data['phone'] = $info['phone'];
        $data['wechat_num'] = $info['wechat_num'];
        $data['email'] = $info['email'];
        $data['company'] = $info['company'];
        $data['address'] = $info['address'];
        return self::where("w_id",'=',$wu_id)->update($data);
    }

    /**
     * 更新用户电话
     * @param $info
     * @param $wu_id
     * @return $this
     */
    public function updatePhone($info,$wu_id){
        $data['phone'] = $info['phone'];
        return self::where("w_id",'=',$wu_id)->update($data);
    }


}